<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../head.jsp"%>
<%@ include file="../kindeditor.jsp"%><!-- kindeditor -->
<body>
<%@ include file="../navbar.jsp"%><!--导航 -->
<div class="container widget">
	<div class="toolbar text-right"></div>
	<div class="">
		<form id="bannerInfo" action="${ctx}/banner/addBanner" class="form-horizontal" role="form" method="post">
			<div class="form-group">
				<label class="col-xs-2 control-label">banner名称</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="bannerName" maxlength="50" placeholder="请输入名称">
			     </div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label">banner类型</label>
			     <div class="col-xs-8">
			     	<select class="form-control" name="bannerType">
				    	<option value="0">首页</option>
				    	<option value="1">德燊介绍</option>
				    	<option value="2">业务信息</option>
				    	<option value="3">公告信息</option>
				    	<option value="4">加入我们</option>
				    	<option value="5">其他</option>
				    </select>
			     </div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label">banner地址</label>
			     <div class="col-xs-8">
			     	<input type="hidden" class="form-control" id="bannerImgUrl" name="bannerImgUrl">
			     	<input type="button" id="bannerImg" value="选择图片" />
			     	<label id="upload_info"></label>
			     </div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label"></label>
			     <div class="col-xs-8">
			     	<img id="showImg" alt="" src="" width="720px;" height="200px;"/>
			     </div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label">排序号</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="sort" placeholder="请输入排序号"  maxlength="3" onkeyup="value=value.replace(/[^0-9]/gi,'')">
			     </div>
			</div>
			<div class="form-group">
		      <div class="col-xs-offset-2 col-xs-10">
		         <input type="text" class="btn btn-info" id="save_btn" value="保存"/>
		      </div>
		   </div>
		</form>
	</div>
</div>

<script type="text/javascript">
	document.title = "德燊后台-Banner新增";//修改标题
	var editor;
	KindEditor.ready(function(K) {
		editor = K.editor({
			uploadJson : '${ctx}/upload.do',
			fileManagerJson : '${ctx}/fileManager.do',
			allowFileManager : true
		});
		K('#bannerImg').click(function() {
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					imageUrl : K('#bannerImgUrl').val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#bannerImgUrl').val(url);
						K('#showImg').attr("src", url);
						editor.hideDialog();
					}
				});
			});
		});
	});
	$(function(){
		var rstCode = '${resultCode}';
		var rstMsg = '${resultMsg}';
		if(rstCode != "" && rstMsg != ""){
			if(rstCode == 1){
				alert(rstMsg);
				location.href = "${ctx}/banner/findBanner";
			}else if(rstCode == 0){
				alert(rstMsg);
			}
		}
	}); 
	/* 保存 */
	$("#save_btn").click(function(){
		var bannerName = $.trim($("input[name='bannerName']").val());
		if(bannerName == ""){
			alert("请输入banner名称");
			return;
		}
		var bannerImgUrl = $.trim($("input[name='bannerImgUrl']").val());
		if(bannerImgUrl == ""){
			alert("请选择图片");
			return;
		}
		var sort = $.trim($("input[name='sort']").val());
		if(sort == ""){
			alert("请输入排序号");
			return;
		}
		$("#bannerInfo").submit();
	});
</script>
</body>

